//
//  BaseScrollViewController.swift
//  SwiftProject
//
//  Created by 董駸 on 2022/8/9.
//

import UIKit

class BaseScrollViewController: BaseViewController {
    /// 在scrollView上创建contentView 方便约束布局
    let scrollView = UIScrollView()
    let scrollContentView = UIView()
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func initSubviews() {
        super.initSubviews()
        
        view.addSubview(scrollView)
        scrollView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        scrollView.addSubview(scrollContentView)
        scrollContentView.snp.makeConstraints { make in
            make.left.top.equalToSuperview()
            make.width.equalTo(SCREEN_WIDTH)
            make.height.equalTo(SCREEN_HEIGHT)
        }
    }
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        
        if let lastV = scrollContentView.subviews.last {
            scrollContentView.qmui_height = lastV.qmui_bottom + 20
            scrollView.contentSize = CGSize(width: scrollView.qmui_width, height: scrollContentView.qmui_height)
        }
    }
}
